package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtSales;
import com.tudouji.project.mt.service.IMtSalesService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团门店菜品销售主Controller
 * 
 * @author tudouji
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/mt/sales")
public class MtSalesController extends BaseController
{
    @Autowired
    private IMtSalesService mtSalesService;

    /**
     * 查询美团门店菜品销售主列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtSales mtSales)
    {
        startPage();
        List<MtSales> list = mtSalesService.selectMtSalesListPC(mtSales);
        return getDataTable(list);
    }

    /**
     * 导出美团门店菜品销售主列表
     */
    @PreAuthorize("@ss.hasPermi('mt:sales:export')")
    @Log(title = "美团门店菜品销售主", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtSales mtSales)
    {
        List<MtSales> list = mtSalesService.selectMtSalesList(mtSales);
        ExcelUtil<MtSales> util = new ExcelUtil<MtSales>(MtSales.class);
        return util.exportExcel(list, "sales");
    }

    /**
     * 获取美团门店菜品销售主详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:sales:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtSalesService.selectMtSalesById(id));
    }

    /**
     * 新增美团门店菜品销售主
     */
    @PreAuthorize("@ss.hasPermi('mt:sales:add')")
    @Log(title = "美团门店菜品销售主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtSales mtSales)
    {
        return toAjax(mtSalesService.insertMtSales(mtSales));
    }

    /**
     * 修改美团门店菜品销售主
     */
    @PreAuthorize("@ss.hasPermi('mt:sales:edit')")
    @Log(title = "美团门店菜品销售主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtSales mtSales)
    {
        return toAjax(mtSalesService.updateMtSales(mtSales));
    }

    /**
     * 删除美团门店菜品销售主
     */
    @PreAuthorize("@ss.hasPermi('mt:sales:remove')")
    @Log(title = "美团门店菜品销售主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtSalesService.deleteMtSalesByIds(ids));
    }
}
